cannot thread-join the current thread
authorTom Tromey <tromey@redhat.com>
Mon, 27 Aug 2012 16:12:29 +0000 (10:12 -0600)
committerTom Tromey <tromey@redhat.com>
Mon, 27 Aug 2012 16:12:29 +0000 (10:12 -0600)
src/thread.c
test/automated/threads.el

index 01d2fd0d6ebe4bdda11f0c549f140ae508425667..551f3de10e45202a31662e9d7476ceda89b8da09 100644 (file)
@@ -852,6 +852,9 @@ It is an error for a thread to try to join itself.  */)
   CHECK_THREAD (thread);
   tstate = XTHREAD (thread);
 
+  if (tstate == current_thread)
+    error ("cannot join current thread");
+
   if (tstate->m_specpdl != NULL)
     flush_stack_call_func (thread_join_callback, tstate);
 
index b1c2af5960029d4be6b756b1e674c88a09a04695..db6aa41d63a434fa687f124068eb7fb854823ef7 100644 (file)
        (and threads-test-global
            (not (thread-alive-p thread)))))))
 
+(ert-deftest threads-join-self ()
+  "cannot thread-join the current thread"
+  (should-error (thread-join (current-thread))))
+
 (defvar threads-test-binding nil)
 
 (defun threads-test-thread2 ()